package com.king.base;

import java.util.Comparator;

import com.google.common.collect.ComparisonChain;
import com.google.common.collect.Ordering;

/**
 * @author taomk
 * @version 1.0
 * @since 15-3-11 下午2:57
 */
public class ComparableTest {

	public static void main(String [] args) {

	}

	class PersonComparator implements Comparator<Person> {
		@Override public int compare(Person p1, Person p2) {
			return ComparisonChain.start()
					.compare(p1.firstName, p2.firstName)
					.compare(p1.lastName, p2.lastName)
					.compare(p1.age, p2.age)
					.result();
		}
	}

	class PersonOrdering extends Ordering<Person> {
		@Override public int compare(Person p1, Person p2) {
			return ComparisonChain.start()
					.compare(p1.firstName, p2.firstName)
					.compare(p1.lastName, p2.lastName)
					.compare(p1.age, p2.age)
					.result();
		}
	}

	class Person implements Comparable {

		final String firstName;

		final String lastName;

		final int age;

		public Person(String firstName, String lastName, int age) {
			this.firstName = firstName;
			this.lastName = lastName;
			this.age = age;
		}

		@Override
		public int compareTo(Object o) {
			return 0;
		}
	}
}
